package com.nowcoder;

import org.omg.Messaging.SyncScopeHelper;

import java.util.Scanner;

/**
 *ip地址的每段可以看成是一个0-255的整数，把每段拆分成一个二进制形式组合起来，然后把这个二进制数转变成一个长整数。
 */
public class IPConvert {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String ip = in.nextLine();
        Long num = in.nextLong();
        String []ipNums = ip.split("\\.");
        String numIp = "";
        long ipNum = 0;
        for(int i=3; i>=0; i--){
            ipNum += Long.parseLong(ipNums[i]) << (3-i)*8;
            numIp += (num>>(i*8)&255);
            if (i != 0) {
                numIp += ".";
            }
        }
        System.out.println(ipNum);
        System.out.println(numIp);
    }
}
